package com.baseweb.webadmin.controller.admin;

import com.baseweb.webadmin.controller.BaseController;
import com.baseweb.webadmin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping(value = "/operation")
public class OperatorController extends BaseController {
    private final static String PREFIX = "/operation/";

    @Autowired
    private UserService userService;

    private String prefix = "/operator";

    @RequestMapping(value = "/operationManageView")
    public String pushManger() {
        return PREFIX + "operationManageView";
    }

    @RequestMapping(value = "/operationBindingView")
    public String addPushMsgView() {
        return PREFIX + "operationBindingView";
    }

    @RequestMapping(value = "/userList")
    public void viewUsers(@RequestParam(value = "page", defaultValue = "1", required = false) Integer page,
                          @RequestParam(value = "pageSize", defaultValue = "20", required = false) Integer pageSize,
                          @RequestParam(value = "username", required = false) String username,
                          @RequestParam(value = "id", required = false) Integer id,
                          Model model) {

//        List<Role> roles = getSubRoleOfCurrentUser();
//        Map map = new HashMap();
//        map.put("username", username);
//        map.put("searchType", searchType);
//        map.put("roleName", roleName);
//
//        if (roles != null && roles.size() > 0) {
//            List<String> roleNames = new ArrayList<String>();
//            for (Role r : roles) {
//                roleNames.add(r.getRoleName());
//            }
//            map.put("roleNames", roleNames);
//            List<UserRoleBvo> userList = userService.selectUsersByPage(page, pageSize, map);
//
//            model.addAttribute("userRoleBvoList", userList);
//            model.addAttribute("total", userService.getRowsByName(map));
//        } else {
//            model.addAttribute("userRoleBvoList", new ArrayList<UserRoleBvo>());
//            model.addAttribute("total", 0);
//        }
    }
}
